<?php
class Training_DbController extends Zendvn_Controller_Action{
	
	public function init(){
		
	}
	public function index6Action(){
		$tblUser = new Training_Model_User();
		$db = $tblUser->getAdapter();
		// \' '"
		echo '<br>' . $str = "I'm a student.";
		$tmp = $db->quote($str,Zend_Db::INT_TYPE);
		echo '<br>' . $tmp;
		
		$this->_helper->viewRenderer->setNoRender();
	}
	
	
	public function index5Action(){
		echo '<br>' . __METHOD__;
		$tblUser = new Training_Model_User();
		$db = $tblUser->getAdapter();
		
	/*	$bind = array(
							'name'			=> "Mod group",
							'avatar'		=> "avatar.png",
							'ranking'		=> "ranking.png",
							'group_acp'		=> 0,
							'group_default'	=> 0,
							'created'		=> date("Y-m-d H:i:s"),
							'created_by'	=> 1,
							'permission'	=> "Limit Access",
							'status'		=> 1,
							);
		$db->insert('user_group', $bind);*/
		
		//echo '<br>' . $db->lastInsertId('user_group','id');
		$bind = array('name'=>'Member group');
		$where = 'id > 10';
		$db->update('user_group', $bind, $where);
		$this->_helper->viewRenderer->setNoRender();
	}
	
	
	public function index4Action(){
		echo '<br>' . __METHOD__;
		
		$tblUser = new Training_Model_User();
		//$tblUser->setMode();
		//$this->view->slbGroup = $tblUser->fetch('pairs');
		$tmp = $tblUser->fetch('one');
		echo '<pre>';
		print_r($tmp);
		echo '</pre>';
		//$this->_helper->viewRenderer->setNoRender();
	}
	
	public function index3Action(){
		echo '<br>' . __METHOD__;
		
		$model = new Training_Model_UserGroup();
		$this->_helper->viewRenderer->setNoRender();
	}
	
	public function indexAction(){
		echo '<br>' . __METHOD__;
		$this->_helper->viewRenderer();
		
		/*resources.db.params.host = "localhost"
		resources.db.params.username = "root"
		resources.db.params.password = "123456"
		resources.db.params.dbname = "zf-finish"
		resources.db.params.charset = "utf8"*/
		$filename = APPLICATION_PATH . '/configs/application.ini';
		$config = new Zend_Config_Ini($filename,'developer');
		$config = $config->toArray();
		$dbConfig = $config['resources']['db'];
		/*echo '<pre>';
		print_r($dbConfig);
		echo '</pre>';
		
		$adapter = "PDO_MYSQL";
		$config = array('host'=>'localhost',
						'username'=>'root',
						'password'=>'',
						'dbname'=>'zf08',
						'charset'=>'utf8',
						);*/
		$db = Zend_Db::factory($dbConfig['adapter'],$dbConfig['params']);
		echo '<pre>';
		print_r($db);
		echo '</pre>';
		
		/*$tblGroup = new Training_Model_UserGroup();
		$tblGroup->testItem();*/
		/*echo '<pre>';
		print_r($db);
		echo '</pre>';*/
		
		$this->_helper->viewRenderer->setNoRender();
	}
	
	public function index2Action(){
		echo '<br>' . __METHOD__;
		//$this->_helper->viewRenderer();
	}
}